package cn.tedu.csmall.passport.controller;

import cn.tedu.csmall.passport.service.RoleService;
import cn.tedu.csmall.passport.web.JsonResult;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/role/")
@Api(tags = "02.角色管理模块")
@Slf4j
@Validated
public class RoleController {

    @Autowired
    private RoleService roleService;

    @GetMapping("list")
    @PreAuthorize("hasAuthority('/ams/admin/read')")
    @ApiOperation("查询角色列表")
    @ApiOperationSupport(order = 100)
    public JsonResult list() {
        log.debug("开始处理【查询角色列表】的请求，无参数");
        return JsonResult.success(roleService.list());
    }

//    @GetMapping("getStandardById")
//    @ApiOperation("通过id查询一条数据")
//    @ApiOperationSupport(order = 200)
//    public JsonResult getStandardById(@RequestParam @Range(min = 1, message = "根据ID查询相册详情失败，请提供正确的ID值！") Long id) {
//        return JsonResult.success(roleService.getStandardById(id));
//    }
}
